/*
    This file is part of Starlight Engine.

    Starlight Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 2 of the License, or
    (at your option) any later version.

    Starlight Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Starlight Engine.  If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using StarlightEngine;

namespace StarlightEngine
{
    /// <summary>
    /// Manages the engines running textures. Crucial for use of scene loading and saving.
    /// </summary>
    public static class FontManager
    {
        static Dictionary<string, SpriteFont> texts;

        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public static void Initialize()
        {
            texts = new Dictionary<string, SpriteFont>();            
            Logger.Write("FontManager Initialized.", 2);
        }

        
        /// <summary>
        /// Adds the texture.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="texture">The texture.</param>
        public static void AddFont(string name, SpriteFont font)
        {
            if (!texts.ContainsKey(name))
                texts.Add(name, font);
            else
            {
                Logger.Write("Font already loaded.", 3);
            }
        }


        /// <summary>
        /// Adds the texture.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="assetPath">The asset path.</param>
        public static void AddFont(string name, string assetPath)
        {
            if (!texts.ContainsKey(name))
            {
                texts.Add(name, Engine.ContentManager.Load<SpriteFont>(assetPath));
            }
            else
            {
                Logger.Write("Font already loaded.", 3);
            }
        }

        /// <summary>
        /// Gets the texture.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public static SpriteFont GetFont(string name)
        {
            return texts[name];
        }
    }
}